/**
 * @file   Node.h
 * @author xingyifan <xingyifan@xingyifan-VirtualBox>
 * @date   Thu Oct 29 22:15:42 2020
 * 
 * @brief  Here are the declare and the definition of class Node and its functions
 * 
 * 
 */

#include <iostream>

template <typename T>
class Node {
private:
    T  data;
    Node * next;
public:
    Node() { next = NULL; };
    Node(T _val);
    ~Node();
    T get_data();
    void set_data(T _val);
    Node * get_next();
    void set_next(Node * _add);
    void print() const;
};

template <typename T>
void Node<T>::print() const {
    if (data!=NULL) {
	std::cout << data;
    }
}

template <typename T>
void Node<T>::set_next(Node * _add) {
    next = _add;
}

template <typename T>
Node<T> * Node<T>::get_next() {
    return next;
}

template <typename T>
void Node<T>::set_data(T _val) {
    data = _val;
}

template <typename T>
T Node<T>::get_data() {
    return data;
}

template <typename T>
Node<T>::Node(T _val) {
    data = _val;
    next = NULL;
}

template <typename T>
Node<T>::~Node() {
    delete next;
    next = NULL;
}
